www.gusucode.com > VC++ Windows不规则窗体编程的实例演示-源码程序 > VC++ Windows不规则窗体编程的实例演示-源码程序/code/DlgPath.cpp
// DlgPath.cpp : implementation file // Download by http://www.NewXing.com #include "stdafx.h" #include "Irregular.h" #include "DlgPath.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDlgPath dialog CDlgPath::CDlgPath(CWnd* pParent /*=NULL*/) : CDlgBase(CDlgPath::IDD, pParent) { //{{AFX_DATA_INIT(CDlgPath) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CDlgPath::DoDataExchange(CDataExchange* pDX) { CDlgBase::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgPath) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDlgPath, CDlgBase) //{{AFX_MSG_MAP(CDlgPath) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDlgPath message handlers BOOL CDlgPath::OnInitDialog() { CDlgBase::OnInitDialog(); // TODO: Add extra initialization here HRGN wndRgn; CClientDC dc(this); CFont mFont; if (dc.m_hDC!=NULL) { VERIFY(mFont.CreateFont( 200, 50, 0, 0, FW_HEAVY, TRUE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "宋体")); //开始记录窗体轮廓路径 dc.BeginPath(); //设置背景为透明模式,这句话是必须有的。 dc.SetBkMode(TRANSPARENT); CFont * pOldFont; pOldFont = dc.SelectObject( &mFont ); dc.TextOut(0, 0, "Hello"); //结束记录窗体轮廓路径 dc.SelectObject( pOldFont ); dc.EndPath(); //把所记录的路径转化为窗体轮廓句柄 wndRgn = ::PathToRegion(dc.m_hDC); //赋予窗体指定的轮廓形状 this->SetWindowRgn(wndRgn, TRUE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }